﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections.Specialized;

/// <summary>
/// Summary description for ClavidOAuthSuisseID
///
/// $Id: ClavidOAuthSuisseID.cs 13 2011-10-09 15:50:26Z telbie $
/// </summary>
public class ClavidOAuthSuisseID : ClavidOAuth
{

    private const string SUISSE_ID_ATTRIBUTE_PREFIX = "suisseid_";

    public const string SUISSE_ID_NUMBER = SUISSE_ID_ATTRIBUTE_PREFIX + "number";
    public const string SUISSE_ID_EMAIL = SUISSE_ID_ATTRIBUTE_PREFIX + "email";
    public const string SUISSE_ID_NAME = SUISSE_ID_ATTRIBUTE_PREFIX + "name";

    Dictionary<String, String> requestedAttributes = new Dictionary<String, String>();

    private string suisseid_number = null;
    private string suisseid_email = null;
    private string suisseid_name = null;

    public string SuisseIdNumber { get { return suisseid_number; } set { suisseid_number = value; } }
    public string SuisseIdEMail { get { return suisseid_email; } set { suisseid_email = value; } }
    public string SuisseIdName { get { return suisseid_name; } set { suisseid_name = value; } }

    public void setUserLanguage(string language)
    {
        requestedAttributes.Add("user_language", language);
    }

    public void setRequiredAttribute(string attribute)
    {
        requestedAttributes.Add(attribute, "required");
    }

    public void setOptionalAttribute(string attribute)
    {
        requestedAttributes.Add(attribute, "optional");
    }

    public override Dictionary<String, String> getRequestTokenParameters()
    {
        Dictionary<String, String> parameters = base.getRequestTokenParameters();
        parameters.Add("clavid_service", "suisseid");
        foreach (KeyValuePair<String, String> pair in requestedAttributes)
        {
            parameters.Add(pair.Key, pair.Value);
        }
       return parameters;
    }

    public override void setResponseParameters(NameValueCollection parameters)
    {
        this.SuisseIdNumber = parameters.Get(SUISSE_ID_NUMBER);
        this.SuisseIdEMail = parameters.Get(SUISSE_ID_EMAIL);
        this.SuisseIdName = parameters.Get(SUISSE_ID_NAME);

    }

}